<template>
  <div >
    <el-form :inline="true" :model="Searchdata" class="demo-form-inline" >
    <el-form-item label="可视耳号:" style="margin-left: 20px;">
      <el-input v-model="Searchdata.earNumber"  clearable  style="width: 200px" />
    </el-form-item>
    <el-form-item label="电子耳标:" style="margin-left: 20px;">
      <el-input v-model="Searchdata.electronicearnumber"  clearable  style="width: 200px" />
    </el-form-item> 
    <el-form-item label="品种:">
        <el-select v-model="Searchdata.breed" clearable style="width: 200px">
          <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="性别:">
        <el-select v-model="Searchdata.sex" clearable style="width: 200px">
          <el-option v-for="item in sexs" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="出生日期:">
        <el-date-picker
        v-model="Searchdata.startdate"
        type="date"
        style="width: 200px"
      />
      - 
      <el-date-picker
        v-model="Searchdata.enddate"
        type="date"
        style="width: 200px"
        
      />
      </el-form-item><br>
      <el-form-item label="月龄:" style="margin-left: 20px;">
        <el-input v-model="Searchdata.minage"  clearable  style="width: 110px" />-
        <el-input v-model="Searchdata.maxage"  clearable  style="width: 110px" />
      </el-form-item>
      <el-form-item label="生长阶段:" >
          <el-select v-model="Searchdata.growthStage" clearable >
            <el-option v-for="item in sz" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="位置" >
          <el-select v-model="Searchdata.cottage" clearable style="width: 100px" @change="lwlist()">
            <el-option v-for="item in ds" :key="item.Id" :label="item.Name" :value="item.Name"  />
          </el-select>
          <el-select v-model="Searchdata.field" clearable style="width: 100px">
            <el-option v-for="item in lw" :key="item.Id" :label="item.Name" :value="item.Name" /> 
          </el-select>
        </el-form-item>
        <el-form-item label="羊只类型:" >
          <el-select v-model="Searchdata.sheepType" clearable style="width: 180px">
            <el-option v-for="item in yzlx" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="基因等级:" >
          <el-select v-model="Searchdata.geneClass" clearable style="width: 205px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="生产等级:" >
          <el-select v-model="Searchdata.productionGrade" clearable >
            <el-option v-for="item in ProductionGrade" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="销售等级:" >
          <el-select v-model="Searchdata.salesGrade" clearable >
            <el-option v-for="item in GetSalesGrade" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="繁殖状态:" >
          <el-select v-model="Searchdata.reproductiveState" clearable style="width: 170px">
            <el-option v-for="item in GetReproductiveState" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="繁殖状态天数:" >
        <el-input v-model="Searchdata.minstatusdays"  clearable  style="width: 70px" />-
        <el-input v-model="Searchdata.maxstatusdays"  clearable  style="width: 70px" />
      </el-form-item>
      <el-form-item label="父耳号:" >
        <el-input v-model="Searchdata.fatherhorn"  clearable   />
      </el-form-item><br>
      <el-form-item label="母耳号:" style="margin-left: 8px;" >
        <el-input v-model="Searchdata.femalehorn"  clearable   />
      </el-form-item>
      <el-form-item label="在场状态:" >
          <el-select v-model="Searchdata.presence" clearable >
            <el-option v-for="item in GetPresence" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
      <el-form-item >
        <el-button type="danger" @click="SheepFileList()">查询</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
    <el-button @click="dialogVisible = true" type="danger" :icon="Plus">
      新增种公
    </el-button>
    <el-button type="danger" :icon="Plus" @click="dialogVisible2 = true">
      新增种母
    </el-button>
    <el-button type="danger" :icon="Plus" @click="dialogVisible4 = true">
      新增后裔
    </el-button>
    <el-table :data="SheepFile" border style="width: 100%;margin-top: 20px;" :scrollbar-always-on="true" >
    <el-table-column type="selection" width="55"  @selection-change="handleSelectionChange" />
    <el-table-column type="index" :index="indexMethod" label="序号" width="80" />
    <el-table-column prop="earNumber" label="可视耳号" align="center" width="100"  >
      <template v-slot="scope">
        <el-link type="primary" @click="details(scope.row.earNumber)">{{scope.row.earNumber}}</el-link>
      </template>
    </el-table-column>
    <el-table-column prop="electronicEarNumber" label="电子耳号" align="center" width="100" />
    <el-table-column prop="breed" label="品种" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.breed==1">杜泊</span>
        <span v-if="scope.row.breed==2">澳洲白</span>
        <span v-if="scope.row.breed==3">萨福克</span>
        <span v-if="scope.row.breed==4">杜湖</span>
        <span v-if="scope.row.breed==5">杜杜湖</span>
        <span v-if="scope.row.breed==6">萨杜湖</span>
        <span v-if="scope.row.breed==7">澳湖</span>
        <span v-if="scope.row.breed==8">湖羊</span>
        <span v-if="scope.row.breed==9">澳杜湖</span>
      </template>
    </el-table-column>
    <el-table-column prop="sex" label="性别" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.sex==1">公</span>
        <span v-if="scope.row.sex==2">母</span>
      </template>
    </el-table-column>
    <el-table-column prop="birthday" label="出生日期" align="center" width="150"  >
      <template v-slot="scope">
       {{scope.row.birthday.substr(0,10)}}
      </template>
    </el-table-column>
    <el-table-column prop="ageDays" label="日龄" align="center" width="100" />
    <el-table-column prop="ageMoon" label="月龄" align="center" width="100" />
    <el-table-column prop="presence" label="在场状态" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.presence==1">在场</span>
        <span v-if="scope.row.presence==2">待入场</span>
        <span v-if="scope.row.presence==3">销售离场</span>
        <span v-if="scope.row.presence==4">死亡离场</span>
        <span v-if="scope.row.presence==5">淘汰已离场</span>
        <span v-if="scope.row.presence==6">挑拨离场</span>
        <span v-if="scope.row.presence==7">死羔未入场</span>
      </template>
    </el-table-column>
    <el-table-column prop="growthStage" label="阶段" align="center" >
      <template v-slot="scope">
        <span v-if="scope.row.growthStage==1">乳羊</span>
        <span v-if="scope.row.growthStage==2">保育</span>
        <span v-if="scope.row.growthStage==3">后备公羊</span>
        <span v-if="scope.row.growthStage==4">后备母羊</span>
        <span v-if="scope.row.growthStage==5">后备羊</span>
      </template>
    </el-table-column>
    <el-table-column prop="sheepType" label="类型" align="center" >
      <template v-slot="scope">
        <span v-if="scope.row.sheepType==1">种公</span>
        <span v-if="scope.row.sheepType==2">种母</span>
        <span v-if="scope.row.sheepType==3">后裔</span>
      </template>
    </el-table-column>
    <el-table-column prop="cottage" label="栋舍" align="center" width="100" >
    </el-table-column>
    <el-table-column prop="field" label="栏位" align="center" width="100"  />
    <el-table-column prop="reproductiveState" label="繁殖状态" align="center" width="100"  >
      <template v-slot="scope">
        <span v-if="scope.row.reproductiveState==1">后备空怀</span>
        <span v-if="scope.row.reproductiveState==2">返情空怀</span>
        <span v-if="scope.row.reproductiveState==3">未'孕空怀</span>
        <span v-if="scope.row.reproductiveState==4">流产空怀</span>
        <span v-if="scope.row.reproductiveState==5">空胎空怀</span>
        <span v-if="scope.row.reproductiveState==6">断奶空怀</span>
        <span v-if="scope.row.reproductiveState==7">妊娠</span>
        <span v-if="scope.row.reproductiveState==8">哺乳</span>
      </template>
    </el-table-column>
    <el-table-column prop="pregnancyTest" label="是否妊检" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.pregnancyTest==true">已妊检</span>
        <span v-if="scope.row.pregnancyTest==false">未妊检</span>
      </template>
    </el-table-column>
    <el-table-column prop="salesGrade" label="状态天数" align="center" width="100" />
    <el-table-column prop="productionGrade" label="生产等级" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.productionGrade==1">未定级</span>
        <span v-if="scope.row.productionGrade==2">后备级</span>
        <span v-if="scope.row.productionGrade==3">核心级</span>
        <span v-if="scope.row.productionGrade==4">生产级</span>
      </template>
    </el-table-column>
    <el-table-column prop="salesGrade" label="销售等级" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.salesGrade==1">无</span>
        <span v-if="scope.row.salesGrade==2">未定级</span>
      </template>
    </el-table-column>
    <el-table-column prop="geneClass" label="基因等级" align="center" width="100" >
      <template v-slot="scope">
        <span v-if="scope.row.geneClass==1">未定级</span>
        <span v-if="scope.row.geneClass==2">后备级</span>
        <span v-if="scope.row.geneClass==3">核心级</span>
        <span v-if="scope.row.geneClass==4">生产级</span>
      </template>
    </el-table-column>
    <el-table-column prop="birthWeight" label="出生重" align="center" width="100" />
    <el-table-column prop="weaningWeight" label="断奶重" align="center" width="100" />
    <el-table-column prop="weaningDate" label="断奶日期" align="center" width="150" >
      <template v-slot="scope">
       <span v-if="scope.row.weaningDate==null">{{scope.row.weaningDate}}</span>
       <span v-else="scope.row.weaningDate!=null">{{scope.row.weaningDate.substr(0,10)}}</span>
      </template>
    </el-table-column>
    <el-table-column prop="weaningAge" label="断奶日龄" align="center" width="100" />
    <el-table-column prop="fatherHorn" label="父耳号" align="center" width="100" />
    <el-table-column prop="femaleHorn" label="母耳号" align="center" width="100" />
    <el-table-column fixed="right" label="操作" width="120">
      <template v-slot="scope">
        <el-button link type="primary" size="small" @click="Find(scope.row.id)">修改
        </el-button>
        <el-button link type="primary" size="small" @click="del(scope.row.id)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <table style="width: 300px;margin: 5px auto;">
      <tr>
        <td>
          <el-pagination v-model:current-page="page.pindex" v-model:page-size="page.psize"
            :page-sizes="[15, 20, 30, 40]" :background="true" layout=" slot,total, sizes, prev, pager, next, jumper"
            :total="page.totalCount" @size-change="handleSizeChange" @current-change="handleCurrentChange"
            prev-text="上一页" next-text="下一页" />
        </td>
      </tr>
    </table>
    <el-dialog v-model="dialogVisible">
   <el-form :inline="true">
    <el-button type="danger">新增</el-button>
    <el-button type="danger" @click="submitForm(ruleFormRef)">保存</el-button>
    <el-button type="danger" >撤销</el-button>
    <el-button type="danger" >删除</el-button>
   </el-form>
      <span style="margin-left: 400px;">种公档案-新增</span>
      <el-form ref="ruleFormRef"  style="max-width: 100%" :inline="true" :model="form" :rules="rules" label-width="auto"
        class="demo-ruleForm" status-icon>
        <el-form-item label="耳号" prop="earNumber">
          <el-input v-model="form.earNumber"     />
        </el-form-item>
        <el-form-item label="品种" prop="breed">
          <el-select v-model="form.breed" clearable style="width: 200px">
            <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="电子耳标" prop="electronicEarNumber">
            <el-input v-model="form.electronicEarNumber"     />
        </el-form-item>
        <el-form-item label="基因等级" prop="geneClass">
          <el-select v-model="form.geneClass" clearable style="width: 200px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <br><br>
        <span>出生信息</span><br><br>
        <el-form-item label="父亲耳号" prop="fatherHorn">
            <el-input v-model="form.fatherHorn"     />
        </el-form-item>
        <el-form-item label="母亲耳号" prop="femaleHorn">
            <el-input v-model="form.femaleHorn"     />
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-date-picker
        v-model="form.birthday"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="入场日期" prop="entranceda">
          <el-date-picker
        v-model="form.entranceda"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="出生场地" prop="placeBirth">
          <el-input v-model="form.placeBirth"     />
        </el-form-item>
        <el-form-item label="出生重" prop="birthWeight">
            <el-input v-model="form.birthWeight"     />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
    v-model="form.remark"
    style="width: 800px"
    :rows="2"
    type="textarea"
  />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogVisible1">
   <el-form :inline="true">
    <el-button type="danger">新增</el-button>
    <el-button type="danger" @click="submitForm1(ruleFormRef)">保存</el-button>
    <el-button type="danger" >撤销</el-button>
    <el-button type="danger" >删除</el-button>
   </el-form>
      <span style="margin-left: 400px;">种公档案-修改</span>
      <el-form ref="ruleFormRef"  style="max-width: 100%" :inline="true" :model="form1" :rules="rules" label-width="auto"
        class="demo-ruleForm" status-icon>
        <el-form-item label="耳号" prop="earNumber">
          <el-input v-model="form1.earNumber"     />
        </el-form-item>
        <el-form-item label="品种" prop="breed">
          <el-select v-model="form1.breed" clearable  style="width: 200px">
            <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="电子耳标" prop="electronicEarNumber">
            <el-input v-model="form1.electronicEarNumber"     />
        </el-form-item>
        <el-form-item label="基因等级" prop="geneClass" >
          <el-select v-model="form1.geneClass" clearable style="width: 200px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <br><br>
        <span>出生信息</span><br><br>
        <el-form-item label="父亲耳号" prop="fatherHorn">
            <el-input v-model="form1.fatherHorn"    />
        </el-form-item>
        <el-form-item label="母亲耳号" prop="femaleHorn">
            <el-input v-model="form1.femaleHorn"     />
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-date-picker
        v-model="form1.birthday"
        type="date" 
        value-format="YYYY-MM-DD"
        style="width: 200px"
        />
        </el-form-item>
        <el-form-item label="入场日期" prop="entranceda">
          <el-date-picker
        v-model="form1.entranceda"
        type="date" 
        value-format="YYYY-MM-DD"
        style="width: 200px"
        />
        </el-form-item>
        <el-form-item label="出生场地" prop="placeBirth">
          <el-input v-model="form1.placeBirth"     />
        </el-form-item>
        <el-form-item label="出生重" prop="birthWeight">
            <el-input v-model="form1.birthWeight"     />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
    v-model="form1.remark"
    style="width: 800px"
    :rows="2"
    type="textarea"
  />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogVisible2">
   <el-form :inline="true">
    <el-button type="danger">新增</el-button>
    <el-button type="danger" @click="submitForm2(ruleFormRef)">保存</el-button>
    <el-button type="danger" >撤销</el-button>
    <el-button type="danger" >删除</el-button>
   </el-form>
      <span style="margin-left: 400px;">种母档案-新增</span>
      <el-form ref="ruleFormRef"  style="max-width: 100%" :inline="true" :model="form2" :rules="rules" label-width="auto"
        class="demo-ruleForm" status-icon>
        <el-form-item label="耳号" prop="earNumber">
          <el-input v-model="form2.earNumber"     />
        </el-form-item>
        <el-form-item label="品种" prop="breed">
          <el-select v-model="form2.breed" clearable style="width: 200px">
            <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="电子耳标" prop="electronicEarNumber">
            <el-input v-model="form2.electronicEarNumber"    />
        </el-form-item>
        <el-form-item label="基因等级" prop="geneClass">
          <el-select v-model="form2.geneClass" clearable style="width: 200px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <br><br>
        <span>出生信息</span><br><br>
        <el-form-item label="父亲耳号" prop="fatherHorn">
            <el-input v-model="form2.fatherHorn"     />
        </el-form-item>
        <el-form-item label="母亲耳号" prop="femaleHorn">
            <el-input v-model="form2.femaleHorn"     />
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-date-picker
        v-model="form2.birthday"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="入场日期" prop="entranceda">
          <el-date-picker
        v-model="form2.entranceda"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="出生场地" prop="placeBirth">
          <el-input v-model="form2.placeBirth"     />
        </el-form-item>
        <el-form-item label="出生重" prop="birthWeight">
            <el-input v-model="form2.birthWeight"     />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
    v-model="form2.remark"
    style="width: 800px"
    :rows="2"
    type="textarea"
  />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogVisible3">
   <el-form :inline="true">
    <el-button type="danger">新增</el-button>
    <el-button type="danger" @click="submitForm3(ruleFormRef)">保存</el-button>
    <el-button type="danger" >撤销</el-button>
    <el-button type="danger" >删除</el-button>
   </el-form>
      <span style="margin-left: 400px;">种母档案-修改</span>
      <el-form ref="ruleFormRef"  style="max-width: 100%" :inline="true" :model="form3" :rules="rules" label-width="auto"
        class="demo-ruleForm" status-icon>
        <el-form-item label="耳号" prop="earNumber">
          <el-input v-model="form3.earNumber"     />
        </el-form-item>
        <el-form-item label="品种" prop="breed">
          <el-select v-model="form3.breed" clearable style="width: 200px">
            <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="电子耳标" prop="electronicEarNumber">
            <el-input v-model="form3.electronicEarNumber"     />
        </el-form-item>
        <el-form-item label="基因等级" prop="geneClass">
          <el-select v-model="form3.geneClass" clearable style="width: 200px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <br><br>
        <span>出生信息</span><br><br>
        <el-form-item label="父亲耳号" prop="fatherHorn">
            <el-input v-model="form3.fatherHorn"     />
        </el-form-item>
        <el-form-item label="母亲耳号" prop="femaleHorn">
            <el-input v-model="form3.femaleHorn"     />
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-date-picker
        v-model="form3.birthday"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="入场日期" prop="entranceda">
          <el-date-picker
        v-model="form3.entranceda"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="出生场地" prop="placeBirth">
          <el-input v-model="form3.placeBirth"     />
        </el-form-item>
        <el-form-item label="出生重" prop="birthWeight">
            <el-input v-model="form3.birthWeight"     />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
    v-model="form3.remark"
    style="width: 800px"
    :rows="2"
    type="textarea"
  />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        </div>
      </template>
    </el-dialog>
    
    <el-dialog v-model="dialogVisible4">
     
   <el-form :inline="true">
    <el-button type="danger">新增</el-button>
    <el-button type="danger" @click="submitForm4(ruleFormRef)">保存</el-button>
    <el-button type="danger" >撤销</el-button>
    <el-button type="danger" >删除</el-button>
   </el-form>
      <span style="margin-left: 400px;margin-top: 20px;">后裔档案-添加</span>
      <el-form ref="ruleFormRef"  style="max-width: 100%;margin-top: 20px;" :inline="true" :model="form4" :rules="rules1" label-width="auto"
        class="demo-ruleForm" status-icon>
        <el-form-item label="耳号" prop="earNumber">
          <el-input v-model="form4.earNumber"     />
        </el-form-item>
        <el-form-item label="电子耳标" prop="electronicEarNumber">
            <el-input v-model="form4.electronicEarNumber"    />
        </el-form-item>
        <el-form-item label="父亲耳号" prop="fatherHorn">
            <el-input v-model="form4.fatherHorn"     />
        </el-form-item>
        <br>
        <el-form-item label="母亲耳号" prop="femaleHorn">
            <el-input v-model="form4.femaleHorn"     />
        </el-form-item>
        <el-form-item label="品种" prop="breed">
          <el-select v-model="form4.breed" clearable style="width: 200px">
            <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
          <el-form-item label="性别:">
        <el-select v-model="form4.sex" clearable style="width: 200px">
          <el-option v-for="item in sexs" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
      </el-form-item>
        </el-form-item><br>
        <el-form-item label="对应出生状态:" prop="stateBirth">
          <el-select v-model="form4.stateBirth" clearable style="width: 200px">
            <el-option v-for="item in statebirth" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-date-picker
        v-model="form4.birthday"
        type="date" 
        style="width: 200px"
        value-format="YYYY-MM-DD"
        />
        </el-form-item>
        <el-form-item label="入场日期" prop="entranceda">
          <el-date-picker
        v-model="form4.entranceda"
        value-format="YYYY-MM-DD"
        type="date" 
        style="width: 200px"
        />
        </el-form-item><br>
        <el-form-item label="出生场地" prop="presence">
          <el-select v-model="form4.presence" clearable style="width: 200px">
            <el-option v-for="item in GetPresence" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="出生重" prop="birthWeight">
            <el-input v-model="form4.birthWeight"     />
        </el-form-item>
        <el-form-item label="基因等级:" prop="geneClass" >
          <el-select v-model="form4.geneClass" clearable style="width: 200px">
            <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item><br>
        <el-form-item label="备注" prop="remark">
          <el-input
    v-model="form4.remark"
    style="width: 240px;height: 240px;"
    :rows="2"
    type="textarea"
  />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogVisible5">
     <el-form :inline="true">
      <el-button type="danger">新增</el-button>
      <el-button type="danger" @click="submitForm5(ruleFormRef)">保存</el-button>
      <el-button type="danger" >撤销</el-button>
      <el-button type="danger" >删除</el-button>
     </el-form>
        <span style="margin-left: 400px;margin-top: 20px;">后裔档案-修改</span>
        <el-form ref="ruleFormRef"  style="max-width: 100%;margin-top: 20px;" :inline="true" :model="form5" :rules="rules1" label-width="auto"
          class="demo-ruleForm" status-icon>
          <el-form-item label="耳号" prop="earNumber">
            <el-input v-model="form5.earNumber"     />
          </el-form-item>
          <el-form-item label="电子耳标" prop="electronicEarNumber">
              <el-input v-model="form5.electronicEarNumber"     />
          </el-form-item>
          <el-form-item label="父亲耳号" prop="fatherHorn">
              <el-input v-model="form5.fatherHorn"     />
          </el-form-item>
          <br>
          <el-form-item label="母亲耳号" prop="femaleHorn">
              <el-input v-model="form5.femaleHorn"     />
          </el-form-item>
          <el-form-item label="品种" prop="breed">
            <el-select v-model="form5.breed" clearable style="width: 200px">
              <el-option v-for="item in breed" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
            <el-form-item label="性别:">
          <el-select v-model="form5.sex" clearable style="width: 200px">
            <el-option v-for="item in sexs" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </el-form-item>
          </el-form-item><br>
          <el-form-item label="对应出生状态:" prop="stateBirth">
            <el-select v-model="form5.stateBirth" clearable style="width: 200px">
              <el-option v-for="item in statebirth" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="出生日期" prop="birthday">
            <el-date-picker
          v-model="form5.birthday"
          type="date" 
          style="width: 200px"
          value-format="YYYY-MM-DD"
          />
          </el-form-item>
          <el-form-item label="入场日期" prop="entranceda">
            <el-date-picker
          v-model="form5.entranceda"
          type="date" 
          style="width: 200px"
          value-format="YYYY-MM-DD"
          />
          </el-form-item><br>
          <el-form-item label="出生场地" prop="presence">
            <el-select v-model="form5.presence" clearable style="width: 200px">
              <el-option v-for="item in GetPresence" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="出生重" prop="birthWeight">
              <el-input v-model="form5.birthWeight"    />
          </el-form-item>
          <el-form-item label="基因等级:" >
            <el-select v-model="form5.geneClass" clearable style="width: 200px">
              <el-option v-for="item in jy" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item><br>
          <el-form-item label="备注" prop="remark">
            <el-input
      v-model="form5.remark"
      style="width: 240px;height: 240px;"
      :rows="2"
      type="textarea"
    />
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
          </div>
        </template>
      </el-dialog>
  </div>
</template>
<script setup lang="ts">
import axios from "axios";
import {reactive,ref,onMounted} from "vue"
import {
  Check,
  Delete,
  Edit,
  Message,
  Search,
  Star,
  Plus
} from '@element-plus/icons-vue'
import {ElMessage,ElMessageBox} from "element-plus"
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
import {useRoute,useRouter} from "vue-router"
import Cookies from 'cookies-ts'
const cookie = new Cookies();
const router=new useRouter()
const dialogVisible = ref(false)
const dialogVisible1 = ref(false)
const dialogVisible2 = ref(false)
const dialogVisible3 = ref(false)
const dialogVisible4 = ref(false)
const dialogVisible5 = ref(false)
const ruleFormRef = ref<FormInstance>()
  const handleClick = () => {
  console.log('click')
}
//序号
const indexMethod = (index: number) => {
  var count=(page.pindex-1)*page.psize;
  for(let i=0;i<page.pageCount;i++){
    return index+count+1
  }
}
//对应出生状态
const statebirth=ref()
//对应出生状态下拉
const statebirthlist=()=>{
  axios.get("MYroute/api/LamBing/GetinsertType").then(res=>{
    statebirth.value=res.data;
  })
}
//分页
const page=reactive({
    pindex:1,
    psize:15,
    totalCount:0,
    pageCount:0,
})
//复选框
const handleSelectionChange = (val: any) => {
  
}
const refs=ref([])
const Alldel=()=>{
  var id=refs.value.map(x=>x.id)
  if(refs.value.length==0){
      ElMessage.error("至少选择一项");
      return;
  }

  ElMessageBox.confirm(
    '确认删除吗?',
    '警告',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'error',
    }
  ) 
    .then(() => {
     axios.put("Mroute/api/MarkedCondition/MarkedConditionAlldel?ids="+id).then(res=>{
        if(res.data>0){
            ElMessage.success('删除成功');
            SheepFileList()
        }
        else{
            ElMessage.error('删除失败');
        }
     })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: 'Delete canceled',
      })
    })
}
//验证
const rules1 = reactive<FormRules>({
  earNumber: [
    { required: true, message: '耳号不能为空', trigger: 'blur' },
  ],
  breed: [
    { required: true, message: '请选择品种', trigger: 'blur' },
  ],
  electronicEarNumber: [
    { required: true, message: '电子耳号不能为空', trigger: 'blur' },
  ],
  fatherHorn: [
    { required: true, message: '父亲耳号不能为空', trigger: 'blur' },
  ],
  femaleHorn: [
    { required: true, message: '母亲耳号不能为空', trigger: 'blur' },
  ],
  presence: [
    { required: true, message: '请选择出生场地', trigger: 'blur' },
  ],
  birthWeight: [
    { required: true, message: '出生重不能为空', trigger: 'blur' },
  ],
  geneClass: [
    { required: true, message: '请选择基因等级', trigger: 'blur' },
  ],
  remark: [
    { required: true, message: '请输入备注', trigger: 'blur' },
  ],
  birthday: [
    { required: true, message: '请选择出生日期', trigger: 'blur' },
  ],
  weaningDate: [
    { required: true, message: '请选择入场日期', trigger: 'blur' },
  ],
  stateBirth: [
    { required: true, message: '请选择对应出生状态', trigger: 'blur' },
  ],
})
//验证
const rules = reactive<FormRules>({
  earNumber: [
    { required: true, message: '耳号不能为空', trigger: 'blur' },
  ],
  breed: [
    { required: true, message: '请选择品种', trigger: 'blur' },
  ],
  electronicEarNumber: [
    { required: true, message: '电子耳号不能为空', trigger: 'blur' },
  ],
  geneClass: [
    { required: true, message: '请选择基因等级', trigger: 'blur' },
  ],
  fatherHorn: [
    { required: true, message: '父亲耳号不能为空', trigger: 'blur' },
  ],
  femaleHorn: [
    { required: true, message: '母亲耳号不能为空', trigger: 'blur' },
  ],
  placeBirth: [
    { required: true, message: '请选择出生场地', trigger: 'blur' },
  ],
  birthWeight: [
    { required: true, message: '出生重不能为空', trigger: 'blur' },
  ],
  remark: [
    { required: true, message: '请输入备注', trigger: 'blur' },
  ],
  birthday: [
    { required: true, message: '请选择出生日期', trigger: 'blur' },
  ],
  weaningDate: [
    { required: true, message: '请选择入场日期', trigger: 'blur' },
  ],
})

const handleSizeChange = (val: number) => {
  page.psize = val;
  SheepFileList()
}
const handleCurrentChange = (val: number) => {
  page.pindex = val;
  SheepFileList()
}

//查询条件
const Searchdata=reactive({
  earNumber:"",
  electronicearnumber:"",
  breed:"",
  sex:"",
  startdate:"",
  enddate:"",
  minage:"",
  maxage:"",
  growthStage:"",
  cottage:"",
  field:"",
  sheepType:"",
  geneClass:"",
  productionGrade:"",
  salesGrade:"",
  reproductiveState:"",
  minstatusdays:"",
  maxstatusdays:"",
  fatherhorn:"",
  femalehorn:"",
  presence:""
})
//品种
const breed=ref()
//品种下拉
const breedlist=()=>{
  axios.get("MYroute/api/LamBing/GetBreed").then(res=>{
    breed.value=res.data;
  })
}
//羊只档案
const SheepFile=ref()
//羊只档案显示
const SheepFileList=()=>{
  axios.get("MYroute/api/SheepFile/SheepFileConditionGet",{
    params:{
      pindex:page.pindex,
      psize:page.psize,
      earNumber:Searchdata.earNumber,
      electronicearnumber:Searchdata.electronicearnumber,
      breed:Searchdata.breed || undefined,
      sex:Searchdata.sex || undefined,
      startdate:Searchdata.startdate,
      enddate:Searchdata.enddate,
      minage:Searchdata.minage,
      maxage:Searchdata.maxage,
      growthStage:Searchdata.growthStage || undefined,
      cottage:Searchdata.cottage,
      field:Searchdata.field,
      sheepType:Searchdata.sheepType || undefined,
      geneClass:Searchdata.geneClass || undefined,
      productionGrade:Searchdata.productionGrade || undefined,
      salesGrade:Searchdata.salesGrade || undefined,
      reproductiveState:Searchdata.reproductiveState || undefined,
      minstatusdays:Searchdata.minstatusdays,
      maxstatusdays:Searchdata.maxstatusdays,
      fatherhorn:Searchdata.fatherhorn,
      femalehorn:Searchdata.femalehorn,
      presence:Searchdata.presence || undefined
    }
  }).then(res=>{
      SheepFile.value=res.data.list;
      page.pageCount=res.data.pageCount;
      page.totalCount=res.data.totalCount;
  })
}
//性别
const sexs=ref()
const sexlist=()=>{
  axios.get("MYroute/api/SheepFile/SheepFileConditionSex").then(res=>{
    sexs.value=res.data;
  })
}
//生长阶段
const sz=ref()
const szlist=()=>{
  axios.get("MYroute/api/SheepFile/GetGrowthStage").then(res=>{
    sz.value=res.data;
  })
}

//栋舍
const ds=ref()
const dslist=()=>{
  axios.get("OrganizationRead/api/Cottage/HandleGetCot").then(res=>{
    ds.value=res.data;
    
  })
}
//栏位
const lw=ref()
const lwlist=()=>{ 
  axios.get("OrganizationRead/api/Field/HandleGetSheepFarm?Id="+Searchdata.cottage).then(res=>{
    lw.value=res.data;
  })
}

//羊只类型
const yzlx=ref()
const yzlxlist=()=>{
  axios.get("MYroute/api/SheepFile/GetGrowthSheepType").then(res=>{
    yzlx.value=res.data;
 
  })
}
//基因
const jy=ref()
const jylist=()=>{
  axios.get("MYroute/api/SheepFile/GetGeneClass").then(res=>{
    jy.value=res.data;
  })
}
//生产等级
const ProductionGrade=ref()
const ProductionGradelist=()=>{
  axios.get("MYroute/api/SheepFile/GetProductionGrade").then(res=>{
    ProductionGrade.value=res.data;
  })
}
//销售等级
const GetSalesGrade=ref()
const GetSalesGradelist=()=>{
  axios.get("MYroute/api/SheepFile/GetSalesGrade").then(res=>{
    GetSalesGrade.value=res.data;
  })
}
//繁殖状态
const GetReproductiveState=ref()
const GetReproductiveStatelist=()=>{
  axios.get("MYroute/api/SheepFile/GetReproductiveState").then(res=>{
    GetReproductiveState.value=res.data;
  })
}
//在场
const GetPresence=ref()
const GetPresencelist=()=>{
  axios.get("MYroute/api/SheepFile/GetPresence").then(res=>{
    GetPresence.value=res.data;
  })
}
//删除
const del=(id:number)=>{
  ElMessageBox.confirm(
    '确认删除吗?',
    '警告',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'error',
    }
  )
    .then(() => {
      axios.delete("Mroute/api/SheepFile/SheepFileConditionDelete?id=" + id).then(res => {
        if (res.data > 0) {
          ElMessage.success('删除成功');
          SheepFileList();
        }
        else {
          ElMessage.error('删除失败')
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: 'Delete canceled',
      })
    })
}
//表单
const form=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": 1,
  "sex": 1,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 1,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  "createBy": "string",
  "createDate": "2024-05-16T09:07:41.107Z",
  "stateBirth": 1,
  "entranceda": ""
})

//表单
const form1=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": 1,
  "sex": 1,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 1,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  "createBy": "string",
  "createDate": "2024-05-16T09:07:41.107Z",
  "stateBirth": 1,
  "entranceda": ""
})
const form2=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": 1,
  "sex": 2,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 2,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  "createBy": "string",
  "createDate": "2024-05-16T09:07:41.107Z",
  "stateBirth": 1,
  "entranceda": ""
})
//表单
const form3=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": 1,
  "sex": 2,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 2,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  "createBy": "string",
  "createDate": "2024-05-16T09:07:41.107Z",
  "stateBirth": 1,
  "entranceda": ""
})
const form4=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": "",
  "sex": 1,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 3,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  stateBirth:"",
  entranceda:""
})
//表单
const form5=reactive({
  "id": 0,
  "visualEarSignal": "",
  "electronicEarNumber": "",
  "breed": "",
  "sex": 1,
  "birthday": "",
  "ageDays": 0,
  "ageMoon": 0,
  "presence": 1,
  "growthStage": 1,
  "sheepType": 3,
  "cottage": "",
  "field": "",
  "reproductiveState": 1,
  "pregnancyTest": false,
  "statusDays": 0,
  "productionGrade": 1,
  "salesGrade": 1,
  "geneClass": 1,
  "birthWeight": 0,
  "weaningWeight": 0,
  "weaningAge": 0,
  "fatherHorn": "",
  "femaleHorn": "",
  "earNumber": "",
  "placeBirth": "",
  "remark": "",
  "createBy": "",
  "createDate": "",
  "updateBy": "",
  "updateDate": "",
  stateBirth:"",
  entranceda:"",
  weaningDate:""
})
const Find=(id:number)=>{
  axios.get("MYroute/api/SheepFile/SheepFileConditionFind?id="+id).then(res=>{
    if(res.data.sheepType==1){
    dialogVisible1.value=true
    form1.ageDays=res.data.ageDays;
    form1.ageMoon=res.data.ageMoon;
    form1.birthWeight=res.data.birthWeight;
    form1.birthday=res.data.birthday;
    form1.breed=res.data.breed;
    breedlist();
    form1.cottage=res.data.cottage;
    form1.createBy=res.data.createBy;
    form1.createDate=res.data.createDate;
    form1.earNumber=res.data.earNumber;
    form1.electronicEarNumber=res.data.electronicEarNumber;
    form1.fatherHorn=res.data.fatherHorn;
    form1.femaleHorn=res.data.femaleHorn;
    form1.field=res.data.field;
    form1.geneClass=res.data.geneClass;
    jylist();
    form1.growthStage=res.data.growthStage;
    szlist();
    form1.id=res.data.id;
    form1.placeBirth=res.data.placeBirth;
    form1.pregnancyTest=res.data.pregnancyTest;
    form1.presence=res.data.presence;
    form1.productionGrade=res.data.productionGrade;
    ProductionGradelist();
    form1.remark=res.data.remark;
    form1.reproductiveState=res.data.reproductiveState;
    GetReproductiveStatelist();
    form1.salesGrade=res.data.salesGrade;
    GetSalesGradelist();
    form1.sex=res.data.sex;
    sexlist();
    form1.sheepType=res.data.sheepType;
    yzlxlist()
    form1.statusDays=res.data.statusDays;
    form1.visualEarSignal=res.data.visualEarSignal;
    form1.weaningAge=res.data.weaningAge;
    form1.weaningWeight=res.data.weaningWeight;
    form1.entranceda=res.data.entranceda;
    }
    else if(res.data.sheepType==2){
    dialogVisible3.value=true
    form3.ageDays=res.data.ageDays;
    form3.ageMoon=res.data.ageMoon;
    form3.birthWeight=res.data.birthWeight;
    form3.birthday=res.data.birthday;
    form3.breed=res.data.breed;
    breedlist();
    form3.cottage=res.data.cottage;
    form3.createBy=res.data.createBy;
    form3.createDate=res.data.createDate;
    form3.earNumber=res.data.earNumber;
    form3.electronicEarNumber=res.data.electronicEarNumber;
    form3.fatherHorn=res.data.fatherHorn;
    form3.femaleHorn=res.data.femaleHorn;
    form3.field=res.data.field;
    form3.geneClass=res.data.geneClass;
    jylist();
    form3.growthStage=res.data.growthStage;
    szlist();
    form3.id=res.data.id;
    form3.placeBirth=res.data.placeBirth;
    form3.pregnancyTest=res.data.pregnancyTest;
    form3.presence=res.data.presence;
    form3.productionGrade=res.data.productionGrade;
    ProductionGradelist();
    form3.remark=res.data.remark;
    form3.reproductiveState=res.data.reproductiveState;
    GetReproductiveStatelist();
    form3.salesGrade=res.data.salesGrade;
    GetSalesGradelist();
    form3.sex=res.data.sex;
    sexlist();
    form3.sheepType=res.data.sheepType;
    yzlxlist()
    form3.statusDays=res.data.statusDays;
    form3.visualEarSignal=res.data.visualEarSignal;
    form3.weaningAge=res.data.weaningAge;
    form3.weaningWeight=res.data.weaningWeight;
    form3.entranceda=res.data.entranceda;
    form3.presence=res.data.presence;
    }
    else if(res.data.sheepType==3){
      dialogVisible5.value=true
    form5.ageDays=res.data.ageDays;
    form5.ageMoon=res.data.ageMoon;
    form5.birthWeight=res.data.birthWeight;
    form5.birthday=res.data.birthday;
    form5.breed=res.data.breed;
    breedlist();
    form5.cottage=res.data.cottage;
    form5.createBy=res.data.createBy;
    form5.createDate=res.data.createDate;
    form5.earNumber=res.data.earNumber;
    form5.electronicEarNumber=res.data.electronicEarNumber;
    form5.fatherHorn=res.data.fatherHorn;
    form5.femaleHorn=res.data.femaleHorn;
    form5.field=res.data.field;
    form5.geneClass=res.data.geneClass;
    jylist();
    form5.growthStage=res.data.growthStage;
    szlist();
    form5.id=res.data.id;
    form5.placeBirth=res.data.placeBirth;
    form5.pregnancyTest=res.data.pregnancyTest;
    form5.presence=res.data.presence;
    GetPresencelist();
    form5.productionGrade=res.data.productionGrade;
    ProductionGradelist();
    form5.remark=res.data.remark;
    form5.reproductiveState=res.data.reproductiveState;
    GetReproductiveStatelist();
    form5.salesGrade=res.data.salesGrade;
    GetSalesGradelist();
    form5.sex=res.data.sex;
    sexlist();
    form5.sheepType=res.data.sheepType;
    yzlxlist()
    form5.statusDays=res.data.statusDays;
    form5.updateBy=res.data.updateBy;
    form5.updateDate=res.data.updateDate;
    form5.visualEarSignal=res.data.visualEarSignal;
    form5.weaningAge=res.data.weaningAge;
    form5.weaningDate=res.data.weaningDate;
    form5.weaningWeight=res.data.weaningWeight;
    form5.stateBirth=res.data.stateBirth;
    statebirthlist()
    form5.entranceda=res.data.entranceda;
    }
  })
}
//添加
const submitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.post("Mroute/api/SheepFile/SheepFileConditionCreate", form).then(res => {
        if (res.data > 0) {
          ElMessage.success('添加成功');
          dialogVisible.value = false;
          SheepFileList();
        }
        else if(res.data==-1){
          ElMessage.success('该耳号已存在');
        }
        else {
          ElMessage.error('添加失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
//修改
const submitForm1 = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form1).then(res => {
        if (res.data > 0) {
          ElMessage.success('修改成功');
          dialogVisible1.value = false;
          SheepFileList();
        }
        else {
          ElMessage.error('修改失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
const submitForm2 = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.post("Mroute/api/SheepFile/SheepFileConditionCreate", form2).then(res => {
        if (res.data > 0) {
          ElMessage.success('添加成功');
          dialogVisible2.value = false;
          SheepFileList();

        }
        else if(res.data==-1){
          ElMessage.success('该耳号已存在');
        }
        else {
          ElMessage.error('添加失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
//修改
const submitForm3 = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form3).then(res => {
        if (res.data > 0) {
          ElMessage.success('修改成功');
          dialogVisible3.value = false;
          SheepFileList();
        }
        else {
          ElMessage.error('修改失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
const submitForm4 = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.post("Mroute/api/SheepFile/SheepFileConditionCreate", form4).then(res => {
        if (res.data > 0) {
          ElMessage.success('添加成功');
          dialogVisible4.value = false;
          SheepFileList();

        }
        else if(res.data==-1){
          ElMessage.success('该耳号已存在');
        }
        else {
          ElMessage.error('添加失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
//修改
const submitForm5 = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      axios.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form5).then(res => {
        if (res.data > 0) {
          ElMessage.success('修改成功');
          dialogVisible5.value = false;
          SheepFileList();
        }
        else {
          ElMessage.error('修改失败');
        }

      })
    } else {
      console.log('error submit!', fields)
    }
  })

}
const details=(earNumber:string)=>{
  router.push("/EarTag/SheepDetails?earNumber="+earNumber)
  cookie.set('earNumber',earNumber)
}

onMounted(()=>{
  SheepFileList(),
  breedlist(),
  sexlist(),
  szlist(),
  yzlxlist(),
  jylist(),
  ProductionGradelist(),
  GetSalesGradelist(),
  GetReproductiveStatelist(),
  GetPresencelist(),
  dslist(),
  statebirthlist()
})
</script>
<style>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}
</style>